package com.seataxa.order.controller;

import com.seataxa.order.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/****************************************************
 *
 * @author lbf
 * @date 2025/7/16 13:34
 ****************************************************/
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/order/create")
    /**
     * Order 相当于TM，即主动开启分布式全局事务的角色；
     * Stock 相当于 RM
     *
     */
    @GlobalTransactional// 开启分布式事务
    public String create(){
        orderService.create();
        return "生成订单";
    }
}
